<?php
namespace app\admin\controller;
use app\admin\controller\Base;
use tools\server;
use app\admin\model\Role as RoleModel;
use think\Session;
class Index extends Base
{
    public function index()
    {
        return $this->fetch();
    }

    public function welcome(){
        $this->assign('servers',server::info());
        $this->assign('mysqlver',$this->_mysql_version());
        return $this->fetch('index/welcome');
    }

    public function logout(){
        if(Session::has('kj.uname') or Session::has('kj.roles')){
            Session::delete('kj.uname');
            Session::delete('kj.roles');
            Session::delete('kj.uid');
            session_destroy();
        }
        //$res = ['statusCode'=>200,'message'=>'感谢您的工作和付出'];
        //echo json_decode($res);
        $this->success('感谢您的工作和付出！',url('admin/login/index'));
    }

    // 获取mysql版本号
    private function _mysql_version()
    {
        $role = new RoleModel();
        $version = $role->query("select version() as ver");
        return $version[0]['ver'];
    }
}
